10 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
12 if( defined( "MEDIAWIKI" ) ) {
15 require_once( 'Linker.php' );
16 require_once( 'Image.php' );
18 # Get a list of all skins available in /skins/
19 # Build using the regular expression '^(.*).php$'
20 # Array keys are all lower case, array value keep the case used by filename
23 $skinDir = dir($IP.'/skins');
25 # while code from www.php.net
26 while (false !== ($file = $skinDir->read())) {
27 if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
29 $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
35 require_once( 'RecentChange.php' );
41 class RCCacheEntry
extends RecentChange
43 var $secureName, $link;
44 var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
45 var $userlink, $timestamp, $watched;
47 function newFromParent( $rc )
49 $rc2 = new RCCacheEntry
;
50 $rc2->mAttribs
= $rc->mAttribs
;
51 $rc2->mExtra
= $rc->mExtra
;
58 * The main skin class that provide methods and properties for all other skins
59 * including PHPTal skins.
60 * This base class is also the "Standard" skin.
63 class Skin
extends Linker
{
67 var $lastdate, $lastline;
68 var $rc_cache ; # Cache for Enhanced Recent Changes
69 var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
73 /** Constructor, call parent constructor */
74 function Skin() { parent
::Linker(); }
76 function getSkinNames() {
77 global $wgValidSkinNames;
78 return $wgValidSkinNames;
81 /** @return string path to the skin stylesheet */
82 function getStylesheet() { return 'common/wikistandard.css'; }
84 /** @return string skin name */
85 function getSkinName() {
89 function qbSetting() {
90 global $wgOut, $wgUser;
92 if ( $wgOut->isQuickbarSuppressed() ) { return 0; }
93 $q = $wgUser->getOption( 'quickbar' );
94 if ( '' == $q ) { $q = 0; }
98 function initPage( &$out ) {
99 $fname = 'Skin::initPage';
100 wfProfileIn( $fname );
102 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
104 $this->addMetadataLinks($out);
106 wfProfileOut( $fname );
109 function addMetadataLinks( &$out ) {
110 global $wgTitle, $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf, $wgRdfMimeType, $action;
111 global $wgRightsPage, $wgRightsUrl, $wgUseTrackbacks;
113 if( $out->isArticleRelated() ) {
114 # note: buggy CC software only reads first "meta" link
115 if( $wgEnableCreativeCommonsRdf ) {
116 $out->addMetadataLink( array(
117 'title' => 'Creative Commons',
118 'type' => 'application/rdf+xml',
119 'href' => $wgTitle->getLocalURL( 'action=creativecommons') ) );
121 if( $wgEnableDublinCoreRdf ) {
122 $out->addMetadataLink( array(
123 'title' => 'Dublin Core',
124 'type' => 'application/rdf+xml',
125 'href' => $wgTitle->getLocalURL( 'action=dublincore' ) ) );
129 if( $wgRightsPage ) {
130 $copy = Title
::newFromText( $wgRightsPage );
132 $copyright = $copy->getLocalURL();
135 if( !$copyright && $wgRightsUrl ) {
136 $copyright = $wgRightsUrl;
139 $out->addLink( array(
140 'rel' => 'copyright',
141 'href' => $copyright ) );
145 function outputPage( &$out ) {
146 global $wgDebugComments;
148 wfProfileIn( 'Skin::outputPage' );
149 $this->initPage( $out );
151 $out->out( $out->headElement() );
153 $out->out( "\n<body" );
154 $ops = $this->getBodyOptions();
155 foreach ( $ops as $name => $val ) {
156 $out->out( " $name='$val'" );
159 if ( $wgDebugComments ) {
160 $out->out( "<!-- Wiki debugging output:\n" .
161 $out->mDebugtext
. "-->\n" );
164 $out->out( $this->beforeContent() );
166 $out->out( $out->mBodytext
. "\n" );
168 $out->out( $this->afterContent() );
171 $out->out( $out->reportTime() );
173 $out->out( "\n</body></html>" );
176 function getHeadScripts() {
177 global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
178 $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
179 if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
180 $userpage = $wgUser->getUserPage();
181 $userjs = htmlspecialchars( $this->makeUrl(
182 $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
183 'action=raw&ctype='.$wgJsMimeType));
184 $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
190 * To make it harder for someone to slip a user a fake
191 * user-JavaScript or user-CSS preview, a random token
192 * is associated with the login session. If it's not
193 * passed back with the preview request, we won't render
196 * @param string $action
200 function userCanPreview( $action ) {
201 global $wgTitle, $wgRequest, $wgUser;
203 if( $action != 'submit' )
205 if( !$wgRequest->wasPosted() )
207 if( !$wgTitle->userCanEditCssJsSubpage() )
209 return $wgUser->matchEditToken(
210 $wgRequest->getVal( 'wpEditToken' ) );
213 # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
214 function getUserStylesheet() {
215 global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
216 $sheet = $this->getStylesheet();
217 $action = $wgRequest->getText('action');
218 $s = "@import \"$wgStylePath/$sheet\";\n";
219 if($wgContLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
221 $query = "action=raw&ctype=text/css&smaxage=$wgSquidMaxage";
222 $s .= '@import "' . $this->makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI
) . "\";\n" .
223 '@import "'.$this->makeNSUrl( ucfirst( $this->getSkinName() . '.css' ), $query, NS_MEDIAWIKI
) . "\";\n";
225 $s .= $this->doGetUserStyles();
230 * placeholder, returns generated js in monobook
232 function getUserJs() { return; }
235 * Return html code that include User stylesheets
237 function getUserStyles() {
238 global $wgOut, $wgStylePath, $wgLang;
239 $s = "<style type='text/css'>\n";
240 $s .= "/*/*/ /*<![CDATA[*/\n"; # <-- Hide the styles from Netscape 4 without hiding them from IE/Mac
241 $s .= $this->getUserStylesheet();
242 $s .= "/*]]>*/ /* */\n";
248 * Some styles that are set by user through the user settings interface.
250 function doGetUserStyles() {
251 global $wgUser, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
255 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) { # logged in
256 if($wgTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
257 $s .= $wgRequest->getText('wpTextbox1');
259 $userpage = $wgUser->getUserPage();
260 $s.= '@import "'.$this->makeUrl(
261 $userpage->getPrefixedText().'/'.$this->getSkinName().'.css',
262 'action=raw&ctype=text/css').'";'."\n";
266 return $s . $this->reallyDoGetUserStyles();
269 function reallyDoGetUserStyles() {
272 if (($undopt = $wgUser->getOption("underline")) != 2) {
273 $underline = $undopt ?
'underline' : 'none';
274 $s .= "a { text-decoration: $underline; }\n";
276 if( $wgUser->getOption( 'highlightbroken' ) ) {
277 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
280 a.new, #quickbar a.new,
281 a.stub, #quickbar a.stub {
283 text-decoration: inherit;
285 a.new:after, #quickbar a.new:after {
288 text-decoration: $underline;
290 a.stub:after, #quickbar a.stub:after {
293 text-decoration: $underline;
297 if( $wgUser->getOption( 'justify' ) ) {
298 $s .= "#article, #bodyContent { text-align: justify; }\n";
300 if( !$wgUser->getOption( 'showtoc' ) ) {
301 $s .= "#toc { display: none; }\n";
303 if( !$wgUser->getOption( 'editsection' ) ) {
304 $s .= ".editsection { display: none; }\n";
309 function getBodyOptions() {
310 global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
312 extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
314 if ( 0 != $wgTitle->getNamespace() ) {
315 $a = array( 'bgcolor' => '#ffffec' );
317 else $a = array( 'bgcolor' => '#FFFFFF' );
318 if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
319 $wgTitle->userCanEdit() ) {
320 $t = wfMsg( 'editthispage' );
322 if ( !empty($redirect) && $redirect == 'no' ) {
323 $red = "&redirect={$redirect}";
325 if ( !empty($oldid) && ! isset( $diff ) ) {
326 $oid = "&oldid=" . intval( $oldid );
328 $s = $wgTitle->getFullURL( "action=edit{$oid}{$red}" );
329 $s = 'document.location = "' .$s .'";';
330 $a +
= array ('ondblclick' => $s);
333 $a['onload'] = $wgOut->getOnloadHandler();
334 if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
335 if( $a['onload'] != '' ) {
338 $a['onload'] .= 'setupRightClickEdit()';
352 * This will be called immediately after the <body> tag. Split into
353 * two functions to make it easier to subclass.
355 function beforeContent() {
356 return $this->doBeforeContent();
359 function doBeforeContent() {
360 global $wgOut, $wgTitle, $wgContLang;
361 $fname = 'Skin::doBeforeContent';
362 wfProfileIn( $fname );
365 $qb = $this->qbSetting();
367 if( $langlinks = $this->otherLanguages() ) {
373 $borderhack = 'class="top"';
376 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
377 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
380 $left = ($qb == 1 ||
$qb == 3);
381 if($wgContLang->isRTL()) $left = !$left;
384 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
385 $this->logoText() . '</td>';
387 $s .= $this->getQuickbarCompensator( $rows );
389 $l = $wgContLang->isRTL() ?
'right' : 'left';
390 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
392 $s .= $this->topLinks() ;
393 $s .= "<p class='subtitle'>" . $this->pageTitleLinks() . "</p>\n";
395 $r = $wgContLang->isRTL() ?
"left" : "right";
396 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
397 $s .= $this->nameAndLogin();
398 $s .= "\n<br />" . $this->searchForm() . "</td>";
401 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
404 if ( $shove && !$left ) { # Right
405 $s .= $this->getQuickbarCompensator( $rows );
407 $s .= "</tr>\n</table>\n</div>\n";
408 $s .= "\n<div id='article'>\n";
410 $notice = wfGetSiteNotice();
412 $s .= "\n<div id='siteNotice'>$notice</div>\n";
414 $s .= $this->pageTitle();
415 $s .= $this->pageSubtitle() ;
416 $s .= $this->getCategories();
417 wfProfileOut( $fname );
422 function getCategoryLinks () {
423 global $wgOut, $wgTitle, $wgParser;
424 global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
426 if( !$wgUseCategoryMagic ) return '' ;
427 if( count( $wgOut->mCategoryLinks
) == 0 ) return '';
429 # Taken out so that they will be displayed in previews -- TS
430 #if( !$wgOut->isArticle() ) return '';
432 $t = implode ( ' | ' , $wgOut->mCategoryLinks
);
433 $msg = count( $wgOut->mCategoryLinks
) === 1 ?
'categories1' : 'categories';
434 $s = $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Categories' ),
435 wfMsg( $msg ), 'article=' . urlencode( $wgTitle->getPrefixedDBkey() ) )
438 # optional 'dmoz-like' category browser. Will be shown under the list
439 # of categories an article belong to
440 if($wgUseCategoryBrowser) {
441 $s .= '<br /><hr />';
443 # get a big array of the parents tree
444 $parenttree = $wgTitle->getParentCategoryTree();
445 # Skin object passed by reference cause it can not be
446 # accessed under the method subfunction drawCategoryBrowser
447 $tempout = explode("\n", Skin
::drawCategoryBrowser($parenttree, $this) );
448 # Clean out bogus first entry and sort them
451 # Output one per line
452 $s .= implode("<br />\n", $tempout);
458 /** Render the array as a serie of links.
459 * @param array $tree Categories tree returned by Title::getParentCategoryTree
460 * @param object &skin Skin passed by reference
461 * @return string separated by >, terminate with "\n"
463 function drawCategoryBrowser($tree, &$skin) {
465 foreach ($tree as $element => $parent) {
466 if (empty($parent)) {
467 # element start a new list
470 # grab the others elements
471 $return .= Skin
::drawCategoryBrowser($parent, $skin) . ' > ';
473 # add our current element to the list
474 $eltitle = Title
::NewFromText($element);
475 $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
480 function getCategories() {
481 $catlinks=$this->getCategoryLinks();
482 if(!empty($catlinks)) {
483 return "<p class='catlinks'>{$catlinks}</p>";
487 function getQuickbarCompensator( $rows = 1 ) {
488 return "<td width='152' rowspan='{$rows}'> </td>";
492 * This gets called immediately before the </body> tag.
493 * @return string HTML to be put after </body> ???
495 function afterContent() {
496 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
497 return $printfooter . $this->doAfterContent();
500 /** @return string Retrievied from HTML text */
501 function printSource() {
503 $url = htmlspecialchars( $wgTitle->getFullURL() );
504 return wfMsg( 'retrievedfrom', '<a href="'.$url.'">'.$url.'</a>' );
507 function printFooter() {
508 return "<p>" . $this->printSource() .
509 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
512 /** overloaded by derived classes */
513 function doAfterContent() { }
515 function pageTitleLinks() {
516 global $wgOut, $wgTitle, $wgUser, $wgContLang, $wgRequest;
518 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
519 $action = $wgRequest->getText( 'action' );
521 $s = $this->printableLink();
522 $disclaimer = $this->disclaimerLink(); # may be empty
524 $s .= ' | ' . $disclaimer;
527 if ( $wgOut->isArticleRelated() ) {
528 if ( $wgTitle->getNamespace() == NS_IMAGE
) {
529 $name = $wgTitle->getDBkey();
530 $image = new Image( $wgTitle );
531 if( $image->exists() ) {
532 $link = htmlspecialchars( $image->getURL() );
533 $style = $this->getInternalLinkAttributes( $link, $name );
534 $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
538 if ( 'history' == $action ||
isset( $diff ) ||
isset( $oldid ) ) {
539 $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
540 wfMsg( 'currentrev' ) );
543 if ( $wgUser->getNewtalk() ) {
544 # do not show "You have new messages" text when we are viewing our
547 if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
548 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
549 wfMsg('newmessageslink') );
550 $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
552 $wgOut->setSquidMaxage(0);
553 $wgOut->enableClientCache(false);
557 $undelete = $this->getUndeleteLink();
558 if( !empty( $undelete ) ) {
559 $s .= ' | '.$undelete;
564 function getUndeleteLink() {
565 global $wgUser, $wgTitle, $wgContLang, $action;
566 if( (($wgTitle->getArticleId() == 0) ||
($action == "history")) &&
567 ($n = $wgTitle->isDeleted() ) )
569 if ( $wgUser->isAllowed( 'delete' ) ) {
570 $msg = 'thisisdeleted';
572 $msg = 'viewdeleted';
575 $this->makeKnownLink(
576 $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ),
577 wfMsg( 'restorelink' . ($n == 1 ?
'1' : ''), $n ) ) );
582 function printableLink() {
583 global $wgOut, $wgFeedClasses, $wgRequest;
585 $baseurl = $_SERVER['REQUEST_URI'];
586 if( strpos( '?', $baseurl ) == false ) {
591 $baseurl = htmlspecialchars( $baseurl );
592 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
594 $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
595 if( $wgOut->isSyndicated() ) {
596 foreach( $wgFeedClasses as $format => $class ) {
597 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
598 $s .= " | <a href=\"$feedurl\">{$format}</a>";
604 function pageTitle() {
605 global $wgOut, $wgTitle, $wgUser;
607 $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
611 function pageSubtitle() {
614 $sub = $wgOut->getSubtitle();
616 global $wgExtraSubtitle;
617 $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
619 $subpages = $this->subPageSubtitle();
620 $sub .= !empty($subpages)?
"</p><p class='subpages'>$subpages":'';
621 $s = "<p class='subtitle'>{$sub}</p>\n";
625 function subPageSubtitle() {
626 global $wgOut,$wgTitle,$wgNamespacesWithSubpages;
628 if($wgOut->isArticle() && !empty($wgNamespacesWithSubpages[$wgTitle->getNamespace()])) {
629 $ptext=$wgTitle->getPrefixedText();
630 if(preg_match('/\//',$ptext)) {
631 $links = explode('/',$ptext);
634 foreach($links as $link) {
636 if ($c<count($links)) {
637 $growinglink .= $link;
638 $getlink = $this->makeLink( $growinglink, $link );
639 if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time
643 $subpages .= '< ';
645 $subpages .= $getlink;
654 function nameAndLogin() {
655 global $wgUser, $wgTitle, $wgLang, $wgContLang, $wgShowIPinHeader;
657 $li = $wgContLang->specialPage( 'Userlogin' );
658 $lo = $wgContLang->specialPage( 'Userlogout' );
661 if ( $wgUser->isAnon() ) {
662 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) {
665 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
666 $wgLang->getNsText( NS_TALK
) );
668 $s .= $n . ' ('.$tl.')';
670 $s .= wfMsg('notloggedin');
673 $rt = $wgTitle->getPrefixedURL();
674 if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
676 } else { $q = "returnto={$rt}"; }
678 $s .= "\n<br />" . $this->makeKnownLinkObj(
679 Title
::makeTitle( NS_SPECIAL
, 'Userlogin' ),
680 wfMsg( 'login' ), $q );
682 $n = $wgUser->getName();
683 $rt = $wgTitle->getPrefixedURL();
684 $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
685 $wgLang->getNsText( NS_TALK
) );
689 $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
690 $n ) . "{$tl}<br />" .
691 $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Userlogout' ), wfMsg( 'logout' ),
692 "returnto={$rt}" ) . ' | ' .
693 $this->specialLink( 'preferences' );
695 $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ),
701 function getSearchLink() {
702 $searchPage =& Title
::makeTitle( NS_SPECIAL
, 'Search' );
703 return $searchPage->getLocalURL();
706 function escapeSearchLink() {
707 return htmlspecialchars( $this->getSearchLink() );
710 function searchForm() {
712 $search = $wgRequest->getText( 'search' );
714 $s = '<form name="search" class="inline" method="post" action="'
715 . $this->escapeSearchLink() . "\">\n"
716 . '<input type="text" name="search" size="19" value="'
717 . htmlspecialchars(substr($search,0,256)) . "\" />\n"
718 . '<input type="submit" name="go" value="' . wfMsg ('go') . '" /> '
719 . '<input type="submit" name="fulltext" value="' . wfMsg ('search') . "\" />\n</form>";
724 function topLinks() {
728 $s = $this->mainPageLink() . $sep
729 . $this->specialLink( 'recentchanges' );
731 if ( $wgOut->isArticleRelated() ) {
732 $s .= $sep . $this->editThisPage()
733 . $sep . $this->historyLink();
735 # Many people don't like this dropdown box
736 #$s .= $sep . $this->specialPagesList();
738 /* show links to different language variants */
739 global $wgDisableLangConversion, $wgContLang, $wgTitle;
740 $variants = $wgContLang->getVariants();
741 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
742 foreach( $variants as $code ) {
743 $varname = $wgContLang->getVariantname( $code );
744 if( $varname == 'disable' )
746 $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
753 function bottomLinks() {
754 global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
758 if ( $wgOut->isArticleRelated() ) {
759 $s .= '<strong>' . $this->editThisPage() . '</strong>';
760 if ( $wgUser->isLoggedIn() ) {
761 $s .= $sep . $this->watchThisPage();
763 $s .= $sep . $this->talkLink()
764 . $sep . $this->historyLink()
765 . $sep . $this->whatLinksHere()
766 . $sep . $this->watchPageLinksLink();
768 if ($wgUseTrackbacks)
769 $s .= $sep . $this->trackbackLink();
771 if ( $wgTitle->getNamespace() == NS_USER
772 ||
$wgTitle->getNamespace() == NS_USER_TALK
)
775 $id=User
::idFromName($wgTitle->getText());
776 $ip=User
::isIP($wgTitle->getText());
778 if($id ||
$ip) { # both anons and non-anons have contri list
779 $s .= $sep . $this->userContribsLink();
781 if( $this->showEmailUser( $id ) ) {
782 $s .= $sep . $this->emailUserLink();
785 if ( $wgTitle->getArticleId() ) {
787 if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
788 if($wgUser->isAllowed('protect')) { $s .= $sep . $this->protectThisPage(); }
789 if($wgUser->isAllowed('move')) { $s .= $sep . $this->moveThisPage(); }
791 $s .= "<br />\n" . $this->otherLanguages();
796 function pageStats() {
797 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
798 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers;
800 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
801 if ( ! $wgOut->isArticle() ) { return ''; }
802 if ( isset( $oldid ) ||
isset( $diff ) ) { return ''; }
803 if ( 0 == $wgArticle->getID() ) { return ''; }
806 if ( !$wgDisableCounters ) {
807 $count = $wgLang->formatNum( $wgArticle->getCount() );
809 $s = wfMsg( 'viewcount', $count );
813 if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
814 require_once('Credits.php');
815 $s .= ' ' . getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
817 $s .= $this->lastModified();
820 if ($wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
821 $dbr =& wfGetDB( DB_SLAVE
);
822 extract( $dbr->tableNames( 'watchlist' ) );
823 $sql = "SELECT COUNT(*) AS n FROM $watchlist
824 WHERE wl_title='" . $dbr->strencode($wgTitle->getDBKey()) .
825 "' AND wl_namespace=" . $wgTitle->getNamespace() ;
826 $res = $dbr->query( $sql, 'Skin::pageStats');
827 $x = $dbr->fetchObject( $res );
828 $s .= ' ' . wfMsg('number_of_watching_users_pageview', $x->n
);
831 return $s . ' ' . $this->getCopyright();
834 function getCopyright() {
835 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
838 $oldid = $wgRequest->getVal( 'oldid' );
839 $diff = $wgRequest->getVal( 'diff' );
841 if ( !is_null( $oldid ) && is_null( $diff ) && wfMsgForContent( 'history_copyright' ) !== '-' ) {
842 $msg = 'history_copyright';
848 if( $wgRightsPage ) {
849 $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText );
850 } elseif( $wgRightsUrl ) {
851 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
856 $out .= wfMsgForContent( $msg, $link );
860 function getCopyrightIcon() {
861 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
863 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
864 $out = $wgCopyrightIcon;
865 } else if ( $wgRightsIcon ) {
866 $icon = htmlspecialchars( $wgRightsIcon );
867 if ( $wgRightsUrl ) {
868 $url = htmlspecialchars( $wgRightsUrl );
869 $out .= '<a href="'.$url.'">';
871 $text = htmlspecialchars( $wgRightsText );
872 $out .= "<img src=\"$icon\" alt='$text' />";
873 if ( $wgRightsUrl ) {
880 function getPoweredBy() {
882 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
883 $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
887 function lastModified() {
888 global $wgLang, $wgArticle, $wgLoadBalancer;
890 $timestamp = $wgArticle->getTimestamp();
892 $d = $wgLang->timeanddate( $timestamp, true );
893 $s = ' ' . wfMsg( 'lastmodified', $d );
897 if ( $wgLoadBalancer->getLaggedSlaveMode() ) {
898 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
903 function logoText( $align = '' ) {
904 if ( '' != $align ) { $a = " align='{$align}'"; }
907 $mp = wfMsg( 'mainpage' );
908 $titleObj = Title
::newFromText( $mp );
909 if ( is_object( $titleObj ) ) {
910 $url = $titleObj->escapeLocalURL();
915 $logourl = $this->getLogo();
916 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
921 * show a drop-down box of special pages
922 * @TODO crash bug913. Need to be rewrote completly.
924 function specialPagesList() {
925 global $wgUser, $wgOut, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
926 require_once('SpecialPage.php');
928 $pages = SpecialPage
::getPages();
930 // special pages without access restriction
931 foreach ( $pages[''] as $name => $page ) {
932 $a[$name] = $page->getDescription();
935 // Other special pages that are restricted.
936 // Copied from SpecialSpecialpages.php
937 foreach($wgAvailableRights as $right) {
938 if( $wgUser->isAllowed($right) ) {
939 /** Add all pages for this right */
940 if(isset($pages[$right])) {
941 foreach($pages[$right] as $name => $page) {
942 $a[$name] = $page->getDescription();
949 $sp = wfMsg( 'specialpages' );
950 $spp = $wgContLang->specialPage( 'Specialpages' );
952 $s = '<form id="specialpages" method="get" class="inline" ' .
953 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
954 $s .= "<select name=\"wpDropdown\">\n";
955 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
958 foreach ( $a as $name => $desc ) {
959 $p = $wgContLang->specialPage( $name );
960 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
963 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
968 function mainPageLink() {
969 $mp = wfMsgForContent( 'mainpage' );
970 $mptxt = wfMsg( 'mainpage');
971 $s = $this->makeKnownLink( $mp, $mptxt );
975 function copyrightLink() {
976 $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ),
977 wfMsg( 'copyrightpagename' ) );
981 function aboutLink() {
982 $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ),
983 wfMsg( 'aboutsite' ) );
988 function disclaimerLink() {
989 $disclaimers = wfMsg( 'disclaimers' );
990 if ($disclaimers == '-') {
993 return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ),
998 function editThisPage() {
999 global $wgOut, $wgTitle, $wgRequest;
1001 $oldid = $wgRequest->getVal( 'oldid' );
1002 $diff = $wgRequest->getVal( 'diff' );
1003 $redirect = $wgRequest->getVal( 'redirect' );
1005 if ( ! $wgOut->isArticleRelated() ) {
1006 $s = wfMsg( 'protectedpage' );
1008 if ( $wgTitle->userCanEdit() ) {
1009 $t = wfMsg( 'editthispage' );
1011 $t = wfMsg( 'viewsource' );
1015 if ( !is_null( $redirect ) ) { $red = "&redirect={$redirect}"; }
1016 if ( $oldid && ! isset( $diff ) ) {
1017 $oid = '&oldid='.$oldid;
1019 $s = $this->makeKnownLinkObj( $wgTitle, $t, "action=edit{$oid}{$red}" );
1024 function deleteThisPage() {
1025 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1027 $diff = $wgRequest->getVal( 'diff' );
1028 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) {
1029 $t = wfMsg( 'deletethispage' );
1031 $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' );
1038 function protectThisPage() {
1039 global $wgUser, $wgOut, $wgTitle, $wgRequest;
1041 $diff = $wgRequest->getVal( 'diff' );
1042 if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
1043 if ( $wgTitle->isProtected() ) {
1044 $t = wfMsg( 'unprotectthispage' );
1045 $q = 'action=unprotect';
1047 $t = wfMsg( 'protectthispage' );
1048 $q = 'action=protect';
1050 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1057 function watchThisPage() {
1058 global $wgUser, $wgOut, $wgTitle;
1060 if ( $wgOut->isArticleRelated() ) {
1061 if ( $wgTitle->userIsWatching() ) {
1062 $t = wfMsg( 'unwatchthispage' );
1063 $q = 'action=unwatch';
1065 $t = wfMsg( 'watchthispage' );
1066 $q = 'action=watch';
1068 $s = $this->makeKnownLinkObj( $wgTitle, $t, $q );
1070 $s = wfMsg( 'notanarticle' );
1075 function moveThisPage() {
1078 if ( $wgTitle->userCanMove() ) {
1079 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Movepage' ),
1080 wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() );
1082 // no message if page is protected - would be redundant
1087 function historyLink() {
1090 return $this->makeKnownLinkObj( $wgTitle,
1091 wfMsg( 'history' ), 'action=history' );
1094 function whatLinksHere() {
1097 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Whatlinkshere' ),
1098 wfMsg( 'whatlinkshere' ), 'target=' . $wgTitle->getPrefixedURL() );
1101 function userContribsLink() {
1104 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Contributions' ),
1105 wfMsg( 'contributions' ), 'target=' . $wgTitle->getPartialURL() );
1108 function showEmailUser( $id ) {
1109 global $wgEnableEmail, $wgEnableUserEmail, $wgUser;
1110 return $wgEnableEmail &&
1111 $wgEnableUserEmail &&
1112 $wgUser->isLoggedIn() && # show only to signed in users
1113 0 != $id; # we can only email to non-anons ..
1114 # '' != $id->getEmail() && # who must have an email address stored ..
1115 # 0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
1116 # 1 != $wgUser->getOption('disablemail'); # and not disabled
1119 function emailUserLink() {
1122 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
, 'Emailuser' ),
1123 wfMsg( 'emailuser' ), 'target=' . $wgTitle->getPartialURL() );
1126 function watchPageLinksLink() {
1127 global $wgOut, $wgTitle;
1129 if ( ! $wgOut->isArticleRelated() ) {
1130 return '(' . wfMsg( 'notanarticle' ) . ')';
1132 return $this->makeKnownLinkObj( Title
::makeTitle( NS_SPECIAL
,
1133 'Recentchangeslinked' ), wfMsg( 'recentchangeslinked' ),
1134 'target=' . $wgTitle->getPrefixedURL() );
1138 function trackbackLink() {
1141 return "<a href=\"" . $wgTitle->trackbackURL() . "\">"
1142 . wfMsg('trackbacklink') . "</a>";
1145 function otherLanguages() {
1146 global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
1148 if ( $wgHideInterlanguageLinks ) {
1152 $a = $wgOut->getLanguageLinks();
1153 if ( 0 == count( $a ) ) {
1157 $s = wfMsg( 'otherlanguages' ) . ': ';
1159 if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
1160 foreach( $a as $l ) {
1161 if ( ! $first ) { $s .= ' | '; }
1164 $nt = Title
::newFromText( $l );
1165 $url = $nt->escapeFullURL();
1166 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
1168 if ( '' == $text ) { $text = $l; }
1169 $style = $this->getExternalLinkAttributes( $l, $text );
1170 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
1172 if($wgContLang->isRTL()) $s .= '</span>';
1176 function bugReportsLink() {
1177 $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ),
1178 wfMsg( 'bugreports' ) );
1182 function dateLink() {
1183 global $wgLinkCache;
1184 $t1 = Title
::newFromText( gmdate( 'F j' ) );
1185 $t2 = Title
::newFromText( gmdate( 'Y' ) );
1187 $wgLinkCache->suspend();
1188 $id = $t1->getArticleID();
1189 $wgLinkCache->resume();
1192 $s = $this->makeBrokenLink( $t1->getText() );
1194 $s = $this->makeKnownLink( $t1->getText() );
1198 $wgLinkCache->suspend();
1199 $id = $t2->getArticleID();
1200 $wgLinkCache->resume();
1203 $s .= $this->makeBrokenLink( $t2->getText() );
1205 $s .= $this->makeKnownLink( $t2->getText() );
1210 function talkLink() {
1211 global $wgTitle, $wgLinkCache;
1213 if ( NS_SPECIAL
== $wgTitle->getNamespace() ) {
1214 # No discussion links for special pages
1218 if( $wgTitle->isTalkPage() ) {
1219 $link = $wgTitle->getSubjectPage();
1220 switch( $link->getNamespace() ) {
1222 $text = wfMsg('articlepage');
1225 $text = wfMsg('userpage');
1228 $text = wfMsg('wikipediapage');
1231 $text = wfMsg('imagepage');
1234 $text= wfMsg('articlepage');
1237 $link = $wgTitle->getTalkPage();
1238 $text = wfMsg( 'talkpage' );
1241 $wgLinkCache->suspend();
1242 $s = $this->makeLinkObj( $link, $text );
1243 $wgLinkCache->resume();
1248 function commentLink() {
1249 global $wgContLang, $wgTitle, $wgLinkCache;
1251 if ( $wgTitle->getNamespace() == NS_SPECIAL
) {
1254 return $this->makeKnownLinkObj( $wgTitle->getTalkPage(),
1255 wfMsg( 'postcomment' ), 'action=edit§ion=new' );
1258 /* these are used extensively in SkinPHPTal, but also some other places */
1259 /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
1260 $title = Title
::makeTitle( NS_SPECIAL
, $name );
1261 return $title->getLocalURL( $urlaction );
1264 /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
1265 $title = Title
::newFromText( wfMsgForContent($name) );
1266 $this->checkTitle($title, $name);
1267 return $title->getLocalURL( $urlaction );
1270 /*static*/ function makeUrl ( $name, $urlaction='' ) {
1271 $title = Title
::newFromText( $name );
1272 $this->checkTitle($title, $name);
1273 return $title->getLocalURL( $urlaction );
1276 # If url string starts with http, consider as external URL, else
1278 /*static*/ function makeInternalOrExternalUrl( $name ) {
1279 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
1282 return $this->makeUrl( $name );
1286 # this can be passed the NS number as defined in Language.php
1287 /*static*/ function makeNSUrl( $name, $urlaction='', $namespace=NS_MAIN
) {
1288 $title = Title
::makeTitleSafe( $namespace, $name );
1289 $this->checkTitle($title, $name);
1290 return $title->getLocalURL( $urlaction );
1293 /* these return an array with the 'href' and boolean 'exists' */
1294 /*static*/ function makeUrlDetails ( $name, $urlaction='' ) {
1295 $title = Title
::newFromText( $name );
1296 $this->checkTitle($title, $name);
1298 'href' => $title->getLocalURL( $urlaction ),
1299 'exists' => $title->getArticleID() != 0?
true:false
1304 * Make URL details where the article exists (or at least it's convenient to think so)
1306 function makeKnownUrlDetails( $name, $urlaction='' ) {
1307 $title = Title
::newFromText( $name );
1308 $this->checkTitle($title, $name);
1310 'href' => $title->getLocalURL( $urlaction ),
1315 # make sure we have some title to operate on
1316 /*static*/ function checkTitle ( &$title, &$name ) {
1317 if(!is_object($title)) {
1318 $title = Title
::newFromText( $name );
1319 if(!is_object($title)) {
1320 $title = Title
::newFromText( '--error: link target missing--' );
1326 * Build an array that represents the sidebar(s), the navigation bar among them
1331 function buildSidebar() {
1332 global $wgTitle, $action;
1334 $fname = 'SkinTemplate::buildSidebar';
1335 $pageurl = $wgTitle->getLocalURL();
1336 wfProfileIn( $fname );
1339 $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
1340 foreach ($lines as $line) {
1341 if (strpos($line, '*') !== 0)
1343 if (strpos($line, '**') !== 0) {
1344 $line = trim($line, '* ');
1347 if (strpos($line, '|') !== false) { // sanity check
1348 $line = explode( '|' , trim($line, '* '), 2 );
1349 $link = wfMsgForContent( $line[0] );
1352 if (wfEmptyMsg($line[1], $text = wfMsg($line[1])))
1354 if (wfEmptyMsg($line[0], $link))
1356 $href = $this->makeInternalOrExternalUrl( $link );
1357 $bar[$heading][] = array(
1360 'id' => 'n-' . strtr($line[1], ' ', '-'),
1361 'active' => $pageurl == $href
1363 } else { continue; }
1367 wfProfileOut( $fname );